from pymysql import Connection

con = Connection(
    host='localhost',
    port=3306,
    user='root',
    password='mofeiwanli'
)

# 获取游标对象
cursor = con.cursor()
# 选择要操作的数据库
con.select_db('test_2023')
# 执行sql语句
# cursor.execute('select * from t_user')
cursor.execute('select id, login_name from t_user')

# 返回元组对象
result: tuple = cursor.fetchall()
for i in result:
    print(i)

# 关闭连接
con.close()
